package cn.cdeden.knowledge.enums;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

/**
 * @ProjectName : ecm_svn
 * @Package : com.cdyd.ecm.core.watermark.domain.dto
 * @ClassName : FilesWatermarkConfigEnums
 * @Author : Yu.
 * @Description : // TODO
 * @Date : 2024/5/17 14:44
 * @Version : 1.0
 */
@Getter
@AllArgsConstructor
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum FilesWatermarkConfigEnums {
    company_abbreviation("#{[company_abbreviation]}","公司简称","sys","company_abbreviation"),

    company_name("#{[company_name]}","公司名称","sys","company_name"),

    name("#{[name]}","用户账号","user","name"),

    nick_name("#{[nick_name]}","用户昵称","user","nick_name"),

    email("#{[email]}","用户邮箱","user","email"),

    phone("#{[phone]}","用户电话","user","phone"),
    phone04("#{[phone04]}","用户电话后4位","user","phone"),

    dept_name("#{[dept_name]}","用户部门","user","dept_name"),

    yyyyMMdd("#{[yyyyMMdd]}","当前日期","date","yyyyMMdd"),

    yyyyMMddHHmm("#{[yyyy-MM-dd HH:mm]}","当前日期时间","date","yyyy_MM_dd_HH_mm"),

    file_name("#{[file_name]}","文件名称","file","file_name"),

    team_name("#{[team_name]}","团队名称","team","team_name")


    ;

    private final String configCode;
    private final String configName;
    private final String configType;
    private final String code;


    private static final Map<String, FilesWatermarkConfigEnums> CONFIG_CODE_MAP;

    static {
        Map<String, FilesWatermarkConfigEnums> map = new HashMap<>();
        for (FilesWatermarkConfigEnums enums : FilesWatermarkConfigEnums.values()) {
            // 增加对null的检查，确保map的键不为null
            String configCode = enums.getConfigCode();
            if (configCode != null) {
                map.put(configCode, enums);
            }
        }
        CONFIG_CODE_MAP = Collections.unmodifiableMap(map);
    }


    public static FilesWatermarkConfigEnums find(String configCode) {
        if (CONFIG_CODE_MAP.containsKey(configCode)) {
            return CONFIG_CODE_MAP.get(configCode);
        }
        return null;
    }


}
